﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing; 

namespace DevelopmentKit.Cms.Web
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.IgnoreRoute("{*favicon}", new {favicon = @"(.*/)?favicon.ico(/.*)?"});
            /*首页*/
            routes.MapRoute(
                name: Guid.NewGuid().ToString(),
                url: "",
                defaults: new {controller = "Content", action = "Root"}
                );
            routes.MapRoute(
                name: Guid.NewGuid().ToString(),
                url: "index.html",
                defaults: new {controller = "Content", action = "Root"}
                );

            /*一级栏目*/
            routes.MapRoute(
                name: Guid.NewGuid().ToString(),
                url: "{part}",
                defaults: new { controller = "Content", action = "Part" },
                constraints: new { part = @"^\w+" }
                ); 


            /*二级栏目*/
            routes.MapRoute(
                name: Guid.NewGuid().ToString(),
                url: "{parent}/{part}",
                defaults: new {controller = "Content", action = "Part"},
                constraints: new { part =@"^\w+"}
                ); 
            /*三级栏目*/
            routes.MapRoute(
                name: Guid.NewGuid().ToString(),
                url: "{grand}/{parent}/{part}",
                defaults: new { controller = "Content", action = "Part" },
                constraints: new { part = @"^\w+" }
                ); 
            /*三级栏目*/
            routes.MapRoute(
                name: Guid.NewGuid().ToString(),
                url: "{greatgrand}/{grand}/{parent}/{part}",
                defaults: new { controller = "Content", action = "Part" },
                constraints: new { part = @"^\w+" }
                );
   




            /*一级内容*/
            routes.MapRoute(
                name: Guid.NewGuid().ToString(),
                url: "{part}/{id}.html",
                defaults: new { controller = "Content", action = "Detail" },
                constraints: new { id = @"^\w+" }
                );
            /*二级内容*/
            routes.MapRoute(
                name: Guid.NewGuid().ToString(),
                url: "{parent}/{part}/{id}.html",
                defaults: new { controller = "Content", action = "Detail" },
                constraints: new { id = @"^\w+" }
                );
            /*三级内容*/
            routes.MapRoute(
                name: Guid.NewGuid().ToString(),
                url: "{grand}/{parent}/{part}/{id}.html",
                defaults: new { controller = "Content", action = "Detail" },
                constraints: new { id = @"^\w+" }
                );
            /*四级内容*/
            routes.MapRoute(
                name: Guid.NewGuid().ToString(),
                url: "{greatgrand}/{grand}/{parent}/{part}/{id}.html",
                defaults: new { controller = "Content", action = "Detail" },
                constraints: new { id = @"^\w+" }
                );
             
        }
    }
}